<?php

class Error {
	
	private $_code;
	private $_message;
	private $_type;
	
	const _INFO 	= 1;
	const _WARNING	= 2;
	const _ERROR 	= 4;
	
	// Error code
	// DB Error 1xxx
	const _DB_CONNECT_ERROR	= 1001;
	const _DB_SELECT_ERROR	= 1002;
	const _DB_INSERT_ERROR	= 1003;
	const _DB_UPDATE_ERROR	= 1004;
	
	// Parameters 2xxx
	const _RE_EMPTY_VALUE	= 2001;
	
	
	function __construct($_code, $_message, $_type) {
		try {
			$this->setCode		( $_code );
			$this->setMessage 	( $_message );
			$this->setType		( $_type );
		} catch ( IllegalArgumentException $ex ) {
			throw $ex;
		}
	}
	
	/**
	 * @return unknown
	 */
	public function getCode() {
		return $this->_code;
	}
	
	/**
	 * @return unknown
	 */
	public function getMessage() {
		return $this->_message;
	}
	
	/**
	 * @return unknown
	 */
	public function getType() {
		return $this->_type;
	}	
	
	/**
	 * @param unknown_type $_code
	 */
	public function setCode($_code) {
		$this->_code = $_code;
	}
	
	/**
	 * @param unknown_type $_message
	 */
	public function setMessage($_message) {
		$this->_message = $_message;
	}
	
	/**
	 * @param unknown_type $_type
	 */
	public function setType($_type) {
		if ( in_array($_type, array( Error::_INFO, Error::_WARNING, Error::_ERROR ) ) ) {
			$this->_type = $_type;
		} else {
			throw new IllegalArgument("Error type ".$_type." not allowed");
		}
	}


}

?>